导航菜单
首页 >  docker run Docker Docs  > Docker Engine API

Docker Engine API

Docker Engine APITable of contents

Docker provides an API for interacting with the Docker daemon (called the DockerEngine API), as well as SDKs for Go and Python. The SDKs allow you to efficiently build andscale Docker apps and solutions. If Go or Python don't workfor you, you can use the Docker Engine API directly.

For information about Docker Engine SDKs, seeDevelop with Docker Engine SDKs.

The Docker Engine API is a RESTful API accessed by an HTTP client such as wget orcurl, or the HTTP library which is part of most modern programming languages.

View the API reference

You canview the reference for the latest version of the APIorchoose a specific version.

Versioned API and SDK

The version of the Docker Engine API you should use depends upon the version ofyour Docker daemon and Docker client.

A given version of the Docker Engine SDK supports a specific version of theDocker Engine API, as well as all earlier versions. If breaking changes occur,they are documented prominently.

Note

The Docker daemon and client don't necessarily need to be the same versionat all times. However, keep the following in mind.

If the daemon is newer than the client, the client doesn't know about newfeatures or deprecated API endpoints in the daemon.

If the client is newer than the daemon, the client can request APIendpoints that the daemon doesn't know about.

A new version of the API is released when new features are added. The Docker APIis backward-compatible, so you don't need to update code that uses the APIunless you need to take advantage of new features.

To see the highest version of the API your Docker daemon and client support, usedocker version:

$ docker versionClient: Version:27.3.1 API version:1.47 Go version:go1.22.7 Git commit:ce12230 Built: Fri Sep 20 11:38:18 2024 OS/Arch:darwin/arm64 Context:desktop-linuxServer: Docker Desktop 4.36.0 (172961) Engine: Version: 27.3.1 API version: 1.47 (minimum version 1.24) Go version:go1.22.7 Git commit:41ca978 Built:Fri Sep 20 11:41:19 2024 OS/Arch: linux/arm64 Experimental: false ...

You can specify the API version to use in any of the following ways:

When using the SDK, use the latest version. At a minimum, use the versionthat incorporates the API version with the features you need.

When using curl directly, specify the version as the first part of the URL.For instance, if the endpoint is /containers/ you can use/v1.47/containers/.

To force the Docker CLI or the Docker Engine SDKs to use an older versionof the API than the version reported by docker version, set theenvironment variable DOCKER_API_VERSION to the correct version. This workson Linux, Windows, or macOS clients.

$ DOCKER_API_VERSION=1.46

While the environment variable is set, that version of the API is used, evenif the Docker daemon supports a newer version. This environment variabledisables API version negotiation, so you should only use it if you mustuse a specific version of the API, or for debugging purposes.

The Docker Go SDK allows you to enable API version negotiation, automaticallyselects an API version that's supported by both the client and the Docker Enginethat's in use.

For the SDKs, you can also specify the API version programmatically as aparameter to the client object. See theGo constructoror thePython SDK documentation for client.

API version matrixDocker versionMaximum API versionChange log27.31.47changes27.21.47changes27.11.46changes27.01.46changes26.11.45changes26.01.45changes25.01.44changes24.01.43changes23.01.42changes20.101.41changes19.031.40changes18.091.39changes18.061.38changes18.051.37changes18.041.37changes18.031.37changes18.021.36changes17.121.35changes17.111.34changes17.101.33changes17.091.32changes17.071.31changes17.061.30changes17.051.29changes17.041.28changes17.03.11.27changes17.031.26changes1.13.11.26changes1.131.25changes1.121.24changesDeprecated API versions

API versions before v1.24 aredeprecated.You can find archived documentation for deprecated versions of the API in thecode repository on GitHub:

Documentation for API versions 1.23 and before.Documentation for API versions 1.17 and before.

相关推荐: